/* map.h */
/* author: jiqing */
/* create: 2011-12-22 */
/* update: 2011-12-27 */

#ifndef MAP_H_
#define MAP_H_

#include <SDL/SDL.h>
#include <SDL/SDL_gfxPrimitives.h>

/* to use boolean, need include this header file  */
/* your compiler need support C99 */
#include <stdbool.h>    

#define TILE_SIZE 32
#define BLOCK_FLAG_COLOR 0xff0000ff
#define GRID_COLOR 0x00ddffff

struct _Tile
{
	short tile_index;
	bool block;
};

typedef struct _Tile Tile;

void tile_wipe(Tile *);
void tile_copy(Tile *, Tile);

struct _Map
{
	short size_x;
	short size_y;
	Tile * tiles;
};

typedef struct _Map Map;

Map *map_new(short size_x, short size_y);
void map_destroy(Map *map);
bool map_resize(Map *map, short size_x, short size_y);
void map_draw(Map *map, SDL_Surface *screen, SDL_Surface *surf_tile,
              bool show_grid, bool show_block);
Map * map_load(const char *map_file);
void map_save(Map *map, const char *map_file_name);
void map_text_out(Map *map);

#endif
